package com.ja.util;

import com.alibaba.fastjson.JSON;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class TimeUtil {

    public static long parseTime (String startTime ,String endTime) {

        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        long minute =0;
        long second =0;
        try {
            Date startData = simpleDateFormat.parse(startTime);
            Date endData = simpleDateFormat.parse(endTime);

             minute = (startData.getTime() - endData.getTime()) / (1000 * 60);
            System.out.println(minute);
             second = minute * 60;
            System.out.println(second);

        } catch (Exception e) {
            e.printStackTrace();
        }
      return second;
    }





    /*public static String getTime (String startTime ,String endTime) {

       *//* String startTime = "2018-10-10 10:09:00";
        String endTime = "2018-10-10 10:08:00";*//*
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        List<String> list = new ArrayList<>();
        try {
            Date startData = simpleDateFormat.parse(startTime);
            Date endData = simpleDateFormat.parse(endTime);
            System.out.println(startData.getTime());
            System.out.println(endData.getTime());
            long minute = (startData.getTime() - endData.getTime()) / (1000 * 60);
            System.out.println(minute);
            long second = minute * 60;
            System.out.println(second);
            while (second > 0) {
                second--;
                Thread.sleep(1000);
                long h = second / 60 / 60 % 60;
                long m = second / 60 % 60;
                long s  = second % 60;
                System.out.println("还剩" + h + "小时" + m + "分钟" + s + "秒");
                list.add(h+m+s+"");
                *//*if(second == 0){
                    break;
                }*//*
//    return h+":"+m+":"+s;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return JSON.toJSONString(list);
       // return "00:00:00";
    }*/
}
